Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Working With Media Time

The Movie Toolbox provides functions that allow your application to work with the time parameters of a media.

You can use the GetMediaDuration function to determine a media's duration.

The GetMediaTimeScale and SetMediaTimeScale let you determine or establish a media's time scale.

GetMediaDuration

The GetMediaDuration function returns the duration of a media.

pascal TimeValue GetMediaDuration (Media theMedia);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

DESCRIPTION

The GetMediaDuration function returns a time value. This time value indicates the media's duration, and it is expressed in the time scale of the media.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

SetMediaTimeScale

The SetMediaTimeScale function allows your application to set a media's time scale.

pascal void SetMediaTimeScale (Media theMedia,
                                          TimeScale timeScale);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

timeScale
Specifies the media's new time scale.

DESCRIPTION

In response to this request, the Movie Toolbox attempts to adjust the edit list of the appropriate track so that movie playback is unaffected. If you change a media's time scale by setting it to a smaller value, you may lose precision in media time values. In general, you should only increase the time scale value, and you should try to use integer multiples of the existing time scale.

SPECIAL CONSIDERATIONS

Do not use SetMediaTimeScale as a general rule. If you call this function with a number that is not an integer multiple, the duration of the samples vary unpredictably, and their start times tend to drift.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid

GetMediaTimeScale

The GetMediaTimeScale function allows your application to determine a media's time scale.

pascal TimeScale GetMediaTimeScale (Media theMedia);
theMedia
Specifies the media for this operation. Your application obtains this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on NewTrackMedia and GetTrackMedia , respectively).

DESCRIPTION

The GetMediaTimeScale function returns the media's time scale.

ERROR CODES

invalidMedia

-2008

This media is corrupted or invalid


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next